package com.kylin.core.authority.event.repository;

import com.kylin.dal.entity.authority.*;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.persistence.EntityManager;

/**
 * 秒结修复时间处理逻辑汇总
 * @author Damon S.
 * @version v1.0.1
 * @date 2019年11月06日 14:53
 */
@Slf4j
@Component
public final class AuthorizationDataHandler {

    private final JPAQueryFactory authorizationFactory;
    private final QOperateLogEntry qOperateLogEntry;
    private final QRoleEntry qRoleEntry;
    private final QOperationEntry qOperationEntry;
    private final QPermissionEntry qPermissionEntry;
    private final QResourceEntry qResourceEntry;

    public AuthorizationDataHandler(@Qualifier("kylinArtworkEntityManager")EntityManager entityManager) {
        this.authorizationFactory = new JPAQueryFactory(entityManager);
        this.qResourceEntry = QResourceEntry.resourceEntry;
        this.qOperateLogEntry = QOperateLogEntry.operateLogEntry;
        this.qOperationEntry = QOperationEntry.operationEntry;
        this.qRoleEntry = QRoleEntry.roleEntry;
        this.qPermissionEntry = QPermissionEntry.permissionEntry;
    }


    public void on(String event) {
//        PerformanceEntry performanceEntry = PerformanceEntry.builder()
//                .id(event.getAppId().getValue())
//                .name(event.getName())
//                .build();
//        performanceRepository.saveAndFlush(performanceEntry);
//
//        log.info("========>>App aggregate[Id:{}, name:'{}'] created by User[Id:{}] at {} is successfully stored into Database.",
//                event.getAppId().getValue(), event.getName(), event.getCreatedBy(), event.getCreatedAt());
    }
}
